// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store'
import iView from 'iview'
import {
  Tree,
  Loading
} from 'element-ui'
// import i18n from '@/locale'
import config from '@/config'
import importDirective from '@/directive'
import * as filters from '@/filters'
import {
  directive as clickOutside
} from 'v-click-outside-x'
import './index.less'
import '@/assets/icons/iconfont.css'
import '@/assets/icons/system/iconfont.css'
import VOrgTree from 'v-org-tree'
import 'v-org-tree/dist/v-org-tree.css'
// 实际打包时应该不引入mock
/* eslint-disable */
iView.Message.config({
  top: 30
})
Vue.use(iView)
Vue.use(VOrgTree)
Vue.component(Tree.name, Tree)
Vue.use(Loading.directive)
// Vue.use(Tree)
/**
 * @description 生产环境关掉提示
 */
Vue.config.productionTip = false
Vue.prototype.$config = config
Vue.prototype.$pageSizeOpts = [ 10,20,50,100,500]
Vue.prototype.hasPermission = function (pers) {
  let res = []
  if (typeof pers === 'string'){
    res = store.state.user.userRes.filter(item => {
      return item.perms.trim() === pers
    })
  } else {
    res = store.state.user.userRes.filter(item => {
      return pers.includes(item.perms.trim())
    })
  }
  return res.length > 0
}
/**
 * 注册指令
 */
importDirective(Vue)
// 引入全局过滤去
Vue.directive('clickOutside', clickOutside)
// 注册全局过滤器
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})
import plugins from '@/plugins'
Vue.use(plugins)

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  // i18n,
  store,
  render: h => h(App)
})
